<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Console\Commands;

use App\Enums\ArticleTypeEnum;
use App\Enums\IdentityVisibilityEnum;
use App\Models\Article;
use Illuminate\Console\Command;

class InitCantCreateDatas extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'init:cant_create_data';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化用户不能创建的数据';

    /**
     * Create a new command instance.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        Article::query()->firstOrCreate([
            'type' => ArticleTypeEnum::ArticleTypeScore,
        ], [
            'title' => '流动人口积分政策',
            'content' => '流动人口积分政策',
            'source' => '来源',
            'push_time' => time(),
            'identity_visibility' => IdentityVisibilityEnum::ALL,
        ]);
        $this->info('流动人口积分政策初始化完成');
        Article::query()->firstOrCreate([
            'type' => ArticleTypeEnum::ArticleTypeCompanyScore,
        ], [
            'title' => '企业积分政策',
            'content' => '企业积分政策',
            'source' => '来源',
            'push_time' => time(),
            'identity_visibility' => IdentityVisibilityEnum::ALL,
        ]);
        $this->info('企业积分政策初始化完成');
        Article::query()->firstOrCreate([
            'type' => ArticleTypeEnum::ArticleTypePromise,
        ], [
            'title' => '村规民约',
            'content' => '村规民约',
            'source' => '来源',
            'push_time' => time(),
            'identity_visibility' => IdentityVisibilityEnum::ALL,
        ]);
        $this->info('村规民约初始化完成');
        return 0;
    }
}
